import { useGlobSetting } from '@/hooks/setting'
import { useQueryParams } from '@/use/useRoute'
import { openWindow } from '@/use/useWindow'
import { getToken } from '@/utils/auth'
const { apiUrl, urlPrefix } = useGlobSetting()

/**
 * 导出文件
 * @param {*} data,对象
 * @param {*} isPrefix,是否自动加上"?"
 * http://v1.uviewui.com/js/queryParams.html 参考
 */
export const useExport = (url: string, params: object) =>
  openWindow(`${apiUrl + urlPrefix + url + useQueryParams({ ...params, token: getToken() })}`)
